﻿using System;
using System.Collections.Generic;
using System.Text;
using SH;

namespace MTS
{
    /*
    class mtDataPacket
    {
        byte m_version = 0x01;
        byte m_flag = 0x00;
        byte m_packet_type = 0;//0 二进制流 1 PB msg 2 大二进制对象
        byte m_seq = 0;    //序号
        uint m_nClassID = 0; //类ID
        uint m_nFuncID = 0;   //方法ID
        uint m_nNum = 0;  //消息块个数
        shErrorCode m_nResult = 0;
        bool m_bNeedCompress = true;
        bool m_bFinish = false;
        byte[] m_buffer;

        public mtDataPacket()
        {

        }

        public shErrorCode finish()
        {
            return shErrorCode.sh_ec_Success;
        }


        public byte getPacketType { get => m_packet_type; set => m_packet_type = value; }

        //void setCompress(bool bCompress = true);

        public long getSize()
        {
            return m_buffer.Length;
        }

        public void setClassIDAndFuncID(uint CID, uint FID) { m_nClassID = CID; m_nFuncID = FID; }

        public bool isBinaryStream { get => m_packet_type == 0; }
        public bool isPBMessage { get => m_packet_type == 1; }
        public bool isBlob { get => m_packet_type == 2; }
        byte Seq { get => m_seq; set => m_seq = value; }

        public uint ClassID { get => m_nClassID; set => m_nClassID = value; }

        public uint FuncID { get => m_nFuncID; set => m_nFuncID = value; }

        public shErrorCode getResult { get => m_nResult; set => m_nResult = value; }

        //以二进制流封装数据包
        public shErrorCode setBuf(MTSSerializer sc)
        {
            m_buffer = sc.ToArray();
            return shErrorCode.sh_ec_Success;
        }

        public shErrorCode getBuf(ref MTSSerializer sc)
        {
            if (isBinaryStream == false)
                return shErrorCode.sh_ec_UnacceptableProtocol;

            if (m_buffer != null)
            {
                sc.attachBuf(m_buffer);
                return shErrorCode.sh_ec_Success;
            }
            else
            {
                return shErrorCode.sh_ec_NullPointer;
            }
        }


        public uint MessageNum { get => m_nNum; }

        bool isCompressed  {  get => false; }

        bool hasData
        {
            get => m_buffer.Length != 0;
        }
    }
    */
}
